package com.jsd2412.backend.turnRoom.controller;

import com.jsd2412.backend.base.response.JsonResult;
import com.jsd2412.backend.turnRoom.pojo.dto.TurnRoomAddParam;
import com.jsd2412.backend.turnRoom.pojo.dto.TurnRoomQuery;
import com.jsd2412.backend.turnRoom.pojo.vo.TurnRoomVO;
import com.jsd2412.backend.turnRoom.service.TurnRoomService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@Api(tags = "转房记录模块")
@RequestMapping("/v1/turnRoom/")
public class TurnRoomController {
    @Autowired
    private TurnRoomService turnRoomService;

    @PostMapping("add")
    public JsonResult addTurnRoom(TurnRoomAddParam addParam) {
        log.debug("添加转房记录:{}", addParam);
        turnRoomService.addTurnRoom(addParam);
        return JsonResult.ok();
    }

    @GetMapping("select")
    public JsonResult selectTurnRoom(TurnRoomQuery query) {
        log.debug("查询转房记录:{}", query);
        List<TurnRoomVO> list = turnRoomService.selectTurnRoom(query);
        return JsonResult.ok(list);
    }
}
